package fei.zhou.springboot3.business.config;

import fei.zhou.springboot3.business.interceptor.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 描述该类- JPA
 *
 * @author zhoufei
 * @class: MyMvcConfig
 * @date 2021/1/13  16:43
 * @Verson 1.0 -2021/1/13  16:43
 * @see
 */

//使用WebMvcConfigurerAdapter可以来扩展SpringMVC的功能

@Configuration
public class MyMvcConfig extends WebMvcConfigurerAdapter {

    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //SpringBoot已经做好了静态资源(*.css , *.js)映射不拦截
        registry.addInterceptor(new LoginHandlerInterceptor())
                //拦截所有
                .addPathPatterns("/**")
                //排除  /login
                .excludePathPatterns("/login");

    }
}